package mobi.smarthosts;

import static mobi.smarthosts.Configuration.TAG;

/**
 * Wrapper of {@link android.util.Log}
 */
public class Log {

    public static int LEVEL = android.util.Log.VERBOSE;

    public static void v(String msg, Object...args) {
        if (LEVEL<=android.util.Log.VERBOSE)
            android.util.Log.v(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg);
    }

    public static void v(String msg, Throwable t, Object...args) {
        if (LEVEL<=android.util.Log.VERBOSE)
            android.util.Log.v(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg, t);
    }

    public static void d(String msg, Object...args) {
        if (LEVEL<=android.util.Log.DEBUG)
            android.util.Log.d(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg);
    }

    public static void d(String msg, Throwable t, Object...args) {
        if (LEVEL<=android.util.Log.DEBUG)
            android.util.Log.d(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg, t);
    }

    public static void i(String msg, Object...args) {
        if (LEVEL<=android.util.Log.INFO)
            android.util.Log.i(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg);
    }

    public static void i(String msg, Throwable t, Object...args) {
        if (LEVEL<=android.util.Log.INFO)
            android.util.Log.i(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg, t);
    }

    public static void w(String msg, Object...args) {
        if (LEVEL<=android.util.Log.WARN)
            android.util.Log.w(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg);
    }

    public static void w(Throwable t) {
        if (LEVEL<=android.util.Log.WARN)
            android.util.Log.w(TAG, t);
    }

    public static void w(String msg, Throwable t, Object...args) {
        if (LEVEL<=android.util.Log.WARN)
            android.util.Log.w(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg, t);
    }

    public static void e(String msg, Object...args) {
        if (LEVEL<=android.util.Log.ERROR)
            android.util.Log.e(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg);
    }

    public static void e(String msg, Throwable t, Object...args) {
        if (LEVEL<=android.util.Log.ERROR)
            android.util.Log.e(TAG, !Utils.isEmptyArray(args)
                    ? String.format(msg, args) : msg, t);
    }
}
